﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SQLite;

namespace AFT2
{
    [Serializable]
    public class MMSDataObject
    {
        public MMSDataObject(string mid, string phoneNumber, string read, string dataType, string date, string locked, string type, string attachedFile, string body)
        {
            MsgId = mid;
            PhoneNumber = phoneNumber;
            Read = read;
            DataType = dataType;
            Date = date;
            Locked = locked;
            Type = type;
            AttachedFile = attachedFile;
            Body = body;
        }
        public string MsgId { get; set; }
        public string PhoneNumber { get; set; }
        public string Read { get; set; }
        public string Type { get; set; }
        public string DataType { get; set; }
        public string Date { get; set; }
        public string Locked { get; set; }
        public string AttachedFile { get; set; }
        public string Body { get; set; }        
    }

    [Serializable]
    public class MMSDataList
    {
        public List<MMSDataObject> data;
        public MMSDataList()
        {
            this.data = new List<MMSDataObject>();

            SQLiteConnection myConnection = new SQLiteConnection();
            myConnection.ConnectionString = "Data Source=db\\phoneData.db";
            myConnection.Open();
            SQLiteCommand sqlcmd = new SQLiteCommand(myConnection);
            sqlcmd.CommandText = "select * from mms;";
            SQLiteDataReader reader = sqlcmd.ExecuteReader();
            while (reader.Read())
            {

                /*
        private static final String CREATE_MMS_TABLE = "create table mms("
			+ "_id integer primary key autoincrement,"
			+ "m_id text,"
			+ "number text,"
			+ "read text,"
			+ "data_type text,"			
			+ "date text,"
			+ "locked text,"
			+ "type text,"			
			+ "attached_file,"
			+ "body text)";
      */
                this.data.Add(
                    new MMSDataObject(
                        "" + reader["m_id"],
                        "" + reader["number"],
                        "" + reader["read"],
                        "" + reader["data_type"],
                        "" + reader["date"],
                        "" + reader["locked"],
                        "" + reader["type"],
                        "" + reader["attached_file"],
                        "" + reader["body"])
                    );
            }

            reader.Close();
            myConnection.Close();
        }       
    }

}
